# -*- coding: utf-8 -*-
"""
社交互动 - Django Admin配置
"""

from django.contrib import admin
from .models import (
    ActivityComment, CommentLike, ActivityRating,
    ActivityDiscussion, DiscussionReply
)


@admin.register(ActivityComment)
class ActivityCommentAdmin(admin.ModelAdmin):
    """活动评论管理"""
    list_display = ('user', 'activity', 'content_preview', 'like_count', 'created_at')
    list_filter = ('created_at',)
    search_fields = ('content', 'user__username', 'activity__title')
    raw_id_fields = ('user', 'activity', 'parent')
    
    def content_preview(self, obj):
        return obj.content[:50] + '...' if len(obj.content) > 50 else obj.content
    content_preview.short_description = '评论内容'


@admin.register(ActivityRating)
class ActivityRatingAdmin(admin.ModelAdmin):
    """活动评分管理"""
    list_display = ('user', 'activity', 'score', 'created_at')
    list_filter = ('score', 'created_at')
    search_fields = ('user__username', 'activity__title')
    raw_id_fields = ('user', 'activity')


@admin.register(ActivityDiscussion)
class ActivityDiscussionAdmin(admin.ModelAdmin):
    """活动讨论管理"""
    list_display = ('title', 'user', 'activity', 'is_pinned', 'reply_count', 'created_at')
    list_filter = ('is_pinned', 'created_at')
    search_fields = ('title', 'content', 'user__username')
    raw_id_fields = ('user', 'activity')


# 简单注册其他模型
admin.site.register(CommentLike)
admin.site.register(DiscussionReply)
